using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using GameFrameWork;
using UnityEngine;

/// <summary>
/// ����ֱ�����
/// </summary>
public class SingleShotStrategy : AttackStrategyBase
{
    public GameObject BulletPrefab;

    public SingleShotStrategy(SkillData data)
    {
        this.AttackData = data;
        this.BulletPrefab = AttackData?.BulletData.Prefab;
    }

    public override void Execute(Entity target)
    {
        base.Execute(target);

        var bulletData = AttackData.BulletData;
        if (bulletData == null)
        {
            Logger.LogError("SingleShotStrategy", $"bulletData:{bulletData == null}");
            return;
        }

        var bullet = BulletPool.Instance.GetBullet(bulletData);
        var parent_pos = Owner.transform.position;
        bullet.transform.position = parent_pos + bulletData.OffVec3;

        var movement = MoveStrategyFactory.Create(bulletData.MoveData);
        bullet.Initialize(
            owner: Owner,
            movement: movement
            );
    }
}
